package cn.edu.ustc.xrovers.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import cn.edu.ustc.xrovers.daoImpl.SamplesDaoImpl;

public class MyContextListener implements ServletContextListener {
	
	private SamplesDaoImpl sdl=new SamplesDaoImpl();

	public void contextDestroyed(ServletContextEvent arg0) {
		ServletContext context=arg0.getServletContext();
		context.removeAttribute("warrantySample");
		context.removeAttribute("classificationSample");
	}

	public void contextInitialized(ServletContextEvent arg0) {
		ServletContext context=arg0.getServletContext();
		if(sdl==null)
			System.out.println("sdl is wrong");
		context.setAttribute("warrantySample", sdl.findWarrantySample());
		context.setAttribute("classificationSample", sdl.findClassificatioinSample());
	}
}
